package com.adam.management.service.impl;

import com.adam.management.mapper.UserMapper;
import com.adam.management.pojo.User;
import com.adam.management.service.UserService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    @Override
    public User getAll() {
        return userMapper.getAll();
    }

    @Override
    public User findByNameAndPassWord(User user) {
        return userMapper.findByNameAndPassWord(user);
    }

    @Override
    public User findByName(User user) {
        return userMapper.findByName(user);
    }

    @Override
    public void createUser(User user) {
        userMapper.createUser(user);
    }

    @Override
    public void updateUser(User user) {
        userMapper.updateUser(user);
    }

    @Override
    public List<User> findAll() {
        return userMapper.findAll();
    }

    @Override
    public List<User> findAllByPage(int currentPage,int pageSize,User search) {
        PageHelper.startPage(currentPage,pageSize);
        return userMapper.findAllByPage(search);
    }

    @Override
    public int count(User search) {
        return userMapper.count(search);
    }

    @Override
    public void delete(int id) {
        userMapper.delete(id);
    }

    @Override
    public User findById(int id) {
        return userMapper.findById(id);
    }
}
